<?php
/*
 * [佳喜网络!] (C)2008-2009 JiaXi Inc.
 * $Id: include.php 2008-8-13 19:28:02 pepsi.zh $
 * -------------------------------------------
 * 网址：www.he88.cn
 * -------------------------------------------
 * 这是一个共享软件，遵循我们公司的共享协议。
*/
include_once('include/include.php');

$outvar[contenttitle] = '修改用户资料';

c_create::createClass('user');
$user = new user();

$userinfo = $user->getUserInfo($_SESSION[userId]);
assignMore($userinfo);
if ($_POST){
	$flag = true;
	if (empty($_POST[zpassword])){
		$flag = false;
		$outvar[zpassword_error] = '原密码不能为空';
	}else {
		$password = md5($_POST[zpassword]);
		$query = "select zuserid from $dbtable->user where UPPER(zusername)=UPPER('$_SESSION[userName]') and zpassword='$password' limit 1";
		if (!($userid = $dbconn->Getonefield($query))){
			$flag = false;
			$outvar[zpassword_error] = '原密码错误';
		}
	}
	if ($_POST[zpassword1]){
		 if($_POST[zpassword1]!=$_POST[zpassword2]){
		 	$flag = false;
			$outvar[zpassword2_error] = '确认新密码有误';
		 }else{
		 	$var[zpassword] = md5($_POST[zpassword1]);
		 }
	}
	$var[zfullname] = $_POST[zfullname];
	if (empty($_POST[zemail])){
		$flag = false;
		$outvar[zemail_error] = '邮箱地址不能为空';
	}else{
		if (!preg_match(PREG_EMAIL,$_POST[zemail])){
			$flag = false;
			$outvar[zemail_error] = '您输入的E-mail格式不正确';
		}else{
			$var[zemail] = $_POST[zemail];
		}
	}
	if ($flag){
		if ($dbconn->updateData($var,$dbtable->user,array('zuserid'=>$userid))){
			$_SESSION[showtip] = '修改成功';
		}else{
			$_SESSION[showtip] = '修改失败';
		}
	}else{
		$_SESSION[showtip] = '修改失败';
	}
}

setnavi(5);
$outvar[includeT] = 'member/userinfo';
outFile('member/main');
?>